<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .target{
        width: 200px;
        height: 200px;
        border: 1px solid black;
        font-size: 30px;
        text-align: center;
        line-height: 200px;
    }
</style>
<body>
    <div class="box">hello!</div>
    <script>
        //获得div元素
        var box = document.querySelector('.box');
        //为获得到的div元素设置className
        box.className='target';
    </script>
</body>
</html>